package com.sl.au.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.Customer;
import com.sl.au.entity.ProductMess;

public interface ProductMessRepository extends JpaRepository<ProductMess, String>{

    /// 产品信息查询
    @Query(" select p from ProductMess p where p.complain.id=?1 and p.typeSpecification like '%'+?2+'%' ")
    Page<ProductMess> findProductMess(String id, String key, Pageable pageable);

    @Query(" select p from ProductMess p where p.complain.id=?1")
    Page<ProductMess> findProductMess(String id, Pageable pageable);

    //产品信息条数
    @Query(" select count(p) from ProductMess p where p.complain.id=?1 and p.typeSpecification like '%'+?2+'%' ")
    Long getCount(String id, String key);

    @Query(" select count(p) from ProductMess p where p.complain.id=?1")
    Long getCount(String id);
    
    //根据投诉建议id找到记录
    List<ProductMess>findByComplain_Id(String complainId);

}
